
package com.work.pdf;

import java.io.*;

import com.vaadin.server.StreamResource.StreamSource;

public class PdfStreamSource implements StreamSource {
	
	private static final long serialVersionUID = 3056897028646156034L;
	
	private ByteArrayOutputStream os;

	public PdfStreamSource() {
		/*Document document = null;

		try {
			os = new ByteArrayOutputStream();
			document = new Document(PageSize.A4, 50, 50, 50, 50);
			PdfWriter.getInstance(document, os);
			document.open();

			document.add(new Paragraph("This iasaaaaaaaaaaaaaaaaaaaaaaaafor the sample PDF!"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (document != null) {
				document.close();
			}
		}*/
	}

	public PdfStreamSource(ByteArrayOutputStream os) {
		this.os = os;
	}

	@Override
	public InputStream getStream()
	{
		return new ByteArrayInputStream(os.toByteArray());
	}
}
